package com.cos.ssm2.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author: COS
 * @time: 2022/6/10 16:29
 * @description:
 */
@Aspect
@Component
public class MyLogAdvice {

    private static final Logger LOG = LoggerFactory.getLogger(MyLogAdvice.class);

    @Pointcut("execution(* com.cos.ssm2.services..*.*(..))")
    public void myPointCut(){}

    @Before("myPointCut()")
    public void log(JoinPoint jp){
        LOG.info("目标:"+jp.getTarget().getClass().getSimpleName()+",方法:"+jp.getSignature().getName()+",time:"+new Date());
    }
}
